<?php
/**
 * Classe de cr�ation des ACL via la vue VACL
**/
include_once "BlM/Vacl.php";


class AclDb extends Zend_Acl	{
	protected $_PrfCtrAct = array();
	public function __construct($app)	{
		$Vacl = new Vacl();
		$this->addRole(new Zend_Acl_Role('invite')); // pour ne pas perturber le fonctionnement de plugauth...
		$privileges = $Vacl->findprivileges($app);
		$this->_setPrivileges($privileges) ;
	}	
	protected function _setPrivileges($privileges)	{
		foreach ($privileges as $privilege)	{
			if (!$this->_getRoleRegistry()->has($privilege->profil)) {
				$this->addRole(new Zend_Acl_Role($privilege->profil));
			}
			if (!array_key_exists($privilege->controleur,$this->_resources)) {
				$this->add(new Zend_Acl_Resource($privilege->controleur));
			}
			$this->allow($privilege->profil,$privilege->controleur,$privilege->action);
			$this->_PrfCtrAct[$privilege->profil][$privilege->controleur][] = $privilege->action;
		}
		return $this ;
	}
	public function getActionCtr($Prf, $Ctr){
		if (array_key_exists($Prf,$this->_PrfCtrAct)) {
			return $this->_PrfCtrAct[$Prf][$Ctr];
		}
	}
}
?>